package cn.wj.school.cloud.config;

import cn.wj.school.cloud.security.interceptor.AuthInterceptor;
import cn.wj.school.cloud.security.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: yueding
 * @Description:
 * @Date: Created in 10:53 2018/5/17
 * @Modified By: mvc拦截器添加 Copyright(c) cai-inc.com
 */
@Configuration
public class MvcInterceptorAutoConfiguration implements WebMvcConfigurer {

    @Autowired
    private AuthInterceptor authInterceptor;
    @Autowired
    private LoginInterceptor loginInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).excludePathPatterns("/static/**");
        registry.addInterceptor(authInterceptor).excludePathPatterns("/static/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
